package config

import (
	"fmt"
	"github.com/spf13/viper"
)

var (
	Nginx_server_name = ""
	FilePath          = ""
)

func ConfInit() {
	viperInit()
	variableInit()
	mysqlInit()
	redisInit()
}

// 变量初始化
func variableInit() {
	Nginx_server_name = viper.GetString("nginx.server_name")
	FilePath = viper.GetString("nginx.filePath")
}
func viperInit() {
	viper.SetConfigName("config") // name of config file (without extension)
	viper.SetConfigType("yaml")   // REQUIRED if the config file does not have the extension in the name
	viper.AddConfigPath(".")
	err := viper.ReadInConfig() // 查找并读取配置文件
	if err != nil {             // 处理读取配置文件的错误
		panic(fmt.Errorf("Fatal error config file: %w \n", err))
	} // path to look for the config file in
}
